import {createVisualEditorConfig} from "../../plugins/menu.registry";
import text from './menus/text'
import button from './menus/button'
import input from './menus/input'
import {createEditorColorProp, createEditorInputProp, createEditorSelectProp} from "../../utils/createEditorProp";




/**
 * 菜单注册
 * @param flag 预留属性
 */
export function useMenuRegistry(flag?: boolean) {
    const {registryComponent, componentList, componentMap} = createVisualEditorConfig()
    registryComponent('text', {
        name: '文本',
        render: text.TextRender,
        preview: text.TextPreview,
        props: {
            text: createEditorInputProp('显示文本','默认文字'),
            color: createEditorColorProp('字体颜色'),
            size: createEditorSelectProp('字体大小', '18px',[
                {label: '14px', value: '14px'},
                {label: '18px', value: '18px'},
                {label: '24px', value: '24px'},
            ])
        }
    })
    registryComponent('button', {
        name: '按钮',
        render: button.ButtonRender,
        preview: button.ButtonPreview,
        props:{
            text: createEditorInputProp('显示文本','按钮啊'),
            type:createEditorSelectProp('按钮类型', '',[
                {label: '默认', value: ''},
                {label: 'primary', value: 'primary'},
                {label: 'dashed', value: 'dashed'},
                {label: 'text', value: 'text'},
                {label: 'link', value: 'link'},
                {label: 'ghost', value: 'ghost'},
            ]),
            size:createEditorSelectProp('按钮尺寸', 'middle',[
                {label: 'middle', value: 'middle'},
                {label: 'large', value: 'large'},
                {label: 'small', value: 'small'},
            ]),
        }

    })
    registryComponent('input', {
        name: '输入框',
        render: input.InputRender,
        preview: input.InputPreview
    })
    return {
        componentMap,
        menuList: componentList
    }
}
